<?php


	namespace app\controllers\api\filter;

	use lib\exception\ApiException;
	use yii\base\ActionFilter;

	class LoginFilter extends ActionFilter
	{

		public function beforeAction ($action) {
			$headers = \Yii::$app->request->headers;

			if (!$headers->has('token')) {
				throw new ApiException('请先登录', -2);
			}

			if ($headers->get('token') != 123456) {
				throw new ApiException('用户信息已过期,请登录', -2);
			}

			return true;
		}

	}
